from peewee import *
from datetime import datetime
from .base import BaseModel, Item, Shop

class Cart(BaseModel):
    id: int = AutoField(primary_key=True)
    name: str = CharField(default='')
    price: int = IntegerField(default=0)
    thumb: str = CharField(default='')
    number: int = IntegerField(default=1)
    item_id: int = ForeignKeyField(Item, to_field='id', default=0, backref='item')
    user_id: int = IntegerField(default=0)
    shop_id: int = ForeignKeyField(Shop, to_field='id', default=0, backref='items')
    checked: int = IntegerField(default=0)
    create_at: int = IntegerField(default=datetime.now().timestamp())  # 创建时间
    update_at: int = IntegerField(default=datetime.now().timestamp())  # 更新时间
    class Meta:
        table_name = 'cart'
